<?php 
/**
 * Description of form
 * @author diotheos
 * @since 7 мая 2010
 */
class App_Form_User_Login extends Zend_Form
{
    /**
     * Initialization of form function
     *
     * @since 7 мая 2010
     * @author diotheos
     * @return Zend_Form
     */
    public function init()
    {
        parent::init();

        $this->setMethod('post');
        $this->setAction('');
        $this->setOptions(array('class' => 'des4forms'));

        $email = new Zend_Form_Element_Text('email');

        $email->setRequired()
                ->setLabel(_('Email:'))
                ->setFilters(array(
                                  'StringToLower',
                                  'StringTrim'
                             ))
                ->addValidators(array(
                                     array('NotEmpty', true),
                                     array('stringLength', false, array(6, 40)),
                                     new Zend_Validate_EmailAddress()
                                ));
        $email->addErrorMessage(_('Input valid email and password'));
        $email->setAttrib('class', 'text-input');
        $email->setDecorators(array('ViewHelper'));
        $this->addElement($email);

        $password = new Zend_Form_Element_Password('password');
        $password->setLabel(_('Password:'));
        $password->addErrorMessage(_('Input valid email and password'));
        $password->setAttrib('class', 'text-input');
        $password->setDecorators(array('ViewHelper'));
        $this->addElement($password);

//                $imgDir = "../public/images/captcha/";
//
//                // check captcha path is writeable
//                if (is_writable($imgDir)) {
//
//                    $captcha = new Zend_Form_Element_Captcha('captcha', array(
//                                                                             'label' => _('Write symbols from image:'),
//                                                                             'captcha' => 'Image',
//                                                                             'captchaOptions' => array(
//                                                                                 'captcha' => 'Image',
//                                                                                 'wordLen' => 6,
//                                                                                 'timeout' => 300,
//                                                                                 'imgDir' => $imgDir,
//                                                                                 'imgUrl' => '/images/captcha',
//                                                                                 'suffix' => '.c.png',
//                                                                                 'font' => dirname(APPLICATION_PATH) .
//                                                                                           "/assets/fonts/Glasten_Bold.ttf",
//                                                                             )
//                                                                        ));
//
//                } else {
//                    $captcha = new Zend_Form_Element_Captcha('captcha', array(
//                                                                             'label' => "Write symbols from image:",
//                                                                             'captcha' => 'Figlet',
//                                                                             'captchaOptions' => array(
//                                                                                 'wordLen' => 6,
//                                                                                 'timeout' => 300,
//                                                                             ),
//                                                                        ));
//                }
//                $captcha->setAttrib('class', 'text-input');
//                $captcha->setDecorators(array('Captcha'));
//                $this->addElement($captcha);

        $remember = new Zend_Form_Element_Checkbox('remember');
        $remember->setLabel('Remember me')
                ->setDecorators(array('ViewHelper'));
        $this->addElement($remember);

        $this->addElement($remember);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel(_('Get in'));
        $submit->setAttrib('class', 'button');
        $submit->setDecorators(array('ViewHelper'));

        $this->addElement($submit);
        $this->setDecorators(array(array('ViewScript', array('viewScript' => '/forms/user/login.phtml'))));

        return $this;
    }
}